﻿@using System.Web.Optimization
@using VideoSeller.Business.Data.Enums
@model FinanceViewModel

@{
	ViewBag.Title = Html.GetGlobalResource("PagesTitles", "CabinetFinance");
    Layout = "~/Views/Shared/_DefaultLayout.cshtml";
}

@section HeadContent {
	@Scripts.Render("~/videoseller/scripts/financescripts")
}

@Html.HiddenFor(x => x.UsdToVsl)
<div class="tabs">
	@Html.Partial("~/Views/Shared/_CabinetTabs.cshtml", CabinetTabs.Finance)
	<div class="tab_content">
		<div class="tab_inner tab_inner_act">
			<table>
				<tr>
					<td>@Html.GetLocalResource("YourAmount")</td>
                    <td>@Html.GetCurrencyString(Model.CurrentMembershipUser.Client.Finance.Total)</td>
				</tr>
				<tr>
					<td>@Html.GetLocalResource("ReffilAmount")</td>
					<td>@Html.TextBoxFor(x => x.RefillAmount)&nbsp;USD&nbsp;&nbsp;<label id="refillAmountDesc"></label></td>
				</tr>
                <tr>
                    <td colspan="2"><div class="paypal_fees_read">@Html.GetLocalResource("PayPalFee")&nbsp;&nbsp;<a href="https://www.paypal.com/at/cgi-bin/webscr?cmd=_display-xborder-fees-outside&countries=">@Html.GetLocalResource("PayPalFeeName")</a></div></td>
                </tr>
				<tr>
					<td></td>
					<td>
						<br/>
						<script src="~/Scripts/paypal-button.min.js?merchant=@Model.PayPalMerchantId"
						        data-env="@Model.PayPalEnvironment"
						        data-button="buynow"
						        data-quantity="1"
						        data-name="VideoSeller Recharge"
						        data-amount="0"
						        data-currency="USD"
						        data-custom="@Model.CurrentMembershipUser.UserId"
						        data-callback="@Model.PayPalCallbackUrl">
						</script>
						<br/>
                        <input id="withdrawalShow" type="button" class="paypal-button-withdraw paypal-button-withdraw-large" value="@Html.GetLocalResource("Withdrawal")"/>
                        @if (Model.PersonalInfoRequired)
                        {
                            <div class="finance_disabled_op_info" id="personalInfoRequired" style="display: none;">@Html.GetLocalResource("PersonalInfoRequired")</div>
                        }
                        else if (Model.NoManyForWithdrawal)
                        {
                            <div class="finance_disabled_op_info" id="noManyForWithdrawal" style="display: none;">@Html.GetLocalResource("NoManyForWithdrawal")</div>
                        }
                        <br /><br />
						<img src="@Url.Content("~/Content/images/payment.jpg")" />
					</td>
				</tr>
			</table>
            <br />          


			<div id="withdrawalPanel" style="display: none;">
				@using (Html.BeginForm("Withdraw", "Cabinet", FormMethod.Post)) {
					<input id="withdrawTypePaypal" type="radio" name="WithdrawType" checked="checked" value="@WithdrawType.PayPal.ToString()"/>
					<label for="withdrawTypePaypal">@Html.GetLocalResource("WithdrawTypePaypal")</label>
                    <br /> 
                    <input id="Email" name="Email" type="text" value="@Model.CurrentMembershipUser.Client.Email"/>
                    <br /><br />            
                    <div>@Html.GetLocalResource("WithdrawalDescription")</div>
					<input type="submit" value="@Html.GetLocalResource("Withdraw")"/>
				}
			</div>
			<br/><br/>
			<div class="postings">
				<table>
					<tr>
                        <th>Id</th>
						<th>@Html.GetLocalResource("Date")</th>
						<th>@Html.GetLocalResource("Operation")</th>
						<th>@Html.GetLocalResource("Amount")</th>
						<th>@Html.GetLocalResource("Comment")</th>
					</tr>
					@foreach (var item in Model.Postings.Take(10)) {
						<tr>
                            <td>@item.Id.ToString()</td>
							<td>@item.Date.ToString("dd MMM yyyy HH:mm:ss")</td>
							<td>@item.OperationEnum.ToString()</td>
							<td>@Html.GetCurrencyString(item.Value)</td>
							<td>@item.Comment</td>
						</tr>
					}
				</table>
			</div>
		</div>
	</div>
</div>